﻿using System;
using System.Text;
using System.Drawing;
using System.Buffers;
using System.Collections;
using System.Collections.Generic;
using System.Runtime.InteropServices;

public static partial class NativeAOT
{
    [UnmanagedCallersOnly(EntryPoint = "ffff")]
    public static unsafe double ffff_dll(double f, int n1, int n2)
    {
        return ffff(f, n1, n2);
    }

    /// <summary>
    /// F_分布函数
    /// </summary>
    /// <param name="f">f随机变量值。要求f>=0。</param>
    /// <param name="n1">n1自由度。</param>
    /// <param name="n2">n2自由度。</param>
    /// <returns>返回F分布函数值。</returns>
    public static unsafe double ffff(double f, int n1, int n2)
    {
        double y;
        if (f < 0.0) f = -f;
        y = inbeta(n2 / 2.0, n1 / 2.0, n2 / (n2 + n1 * f));
        return (y);
    }

    /*
    // F_分布函数例
      int main()
      { 
          int n1,n2,i;
          double y,f;
          int n[2]={ 2,5};
          int m[2]={ 3,10};
          for (i=0; i<=1; i++)
          { 
              n1=n[i]; n2=m[i]; f=3.5;
              y=ffff(f,n1,n2);
              cout <<"P(" <<f <<", " <<n1 <<", " <<n2 <<")=" <<y <<endl;
              f=9.0; y=ffff(f,n1,n2);
              cout <<"P(" <<f <<", " <<n1 <<", " <<n2 <<")=" <<y <<endl;
          }
          return 0;
      }
    */
}

